package com.mao.demo;
// 智能控制系统
// 智能控制系统类，单例类
public class SmartHomeControl {
    private static SmartHomeControl smartHomeControl = new SmartHomeControl();
    private SmartHomeControl() {
    }
    public static SmartHomeControl getInstance() {
        return smartHomeControl;
    }
    public static void printAllStatus(JD[] jds) {
        // 用for循环遍历
        for (int i = 0; i < jds.length; i++) {
            System.out.println((i+1)+jds[i].getName()+"目前开关状态是："+(jds[i].isStatus()?"开着":"关着"));
        }
    }

    public void control(JD jd) {
        System.out.println(jd.getName()+"目前开关状态是："+(jd.isStatus()?"开着":"关着"));
        System.out.println("开始您的操作。。。。");
        jd.press();// 按下开关
        System.out.println(jd.getName()+"目前开关状态已经是："+(jd.isStatus()?"开着":"关着"));

    }
}
